const express = require('express');
const bodyParser = require('body-parser');

//导入路由文件
const user = require('./user/user.js');
const article=require('./article/article.js');

const app = express();

//应用json中间件,获取到请求体中的内容
app.use(bodyParser.json());

//添加表头解决跨域的问题
app.use((req, res, next) => {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "content-type");
  next();
})

//将路由添加到实例
app.use(user);
app.use(article);

//监听端口
app.listen(5000, () => {console.log('已监听5000端口');
})